// Copyright (C) 2003 IFOnlyRT Project.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License 2.0 for more details.

// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/

// Official SVN repository and contact information can be found at
// http://code.google.com/p/ifonlyrt/

#include <iostream>

#include "../../Basics/CColor.hpp"
#include "ErrorHandler.hpp"

int CColor_TestAll();
int CColor_TestStaticsMembers();
int CColor_TestConstructors();
int CColor_TestPublicMethods();
int CColor_TestStaticMethods();

using namespace std;

int CColor_TestAll()
{
	cout << "::CColor - Début des tests..." << endl;

	if(CColor_TestStaticsMembers() != 0) 	return ThrowError("	::CColor - Erreur dans le test des membres statiques !");
	if(CColor_TestConstructors() != 0) 		return ThrowError("	::CColor - Erreur dans le test des constructeurs !");
	if(CColor_TestPublicMethods() != 0) 	return ThrowError("	::CColor - Erreur dans le test des méthodes publiques !");
	if(CColor_TestStaticMethods() != 0) 	return ThrowError("	::CColor - Erreur dans le test des méthodes statiques !");

	cout << "::CColor - OK" << endl << endl;

	return 0;
}

int CColor_TestStaticsMembers()
{
	cout << "	::CColor - Test des membres statiques..." << endl;

	if(CColor::Black != CColor(0, 0, 0)) return -1;
	if(CColor::White != CColor(1, 1, 1)) return -1;
	if(CColor::Red != 	CColor(1, 0, 0)) return -1;
	if(CColor::Green != CColor(0, 1, 0)) return -1;
	if(CColor::Blue != 	CColor(0, 0, 1)) return -1;

	cout << "	::CColor - Membres statiques : OK" << endl;
	return 0;
}

int CColor_TestConstructors()
{
	cout << "	::CColor - Test des constructeurs..." << endl;

	CColor C1;
	if(C1.R != 0 || C1.G != 0 || C1.B != 0) return -1;

	CColor C2(1, 2, 3);
	if(C2.R != 1 || C2.G != 2 || C2.B != 3) return -1;

	CColor C3(8);
	if(C3.R != 8 || C3.G != 8 || C3.B != 8) return -1;

	CColor C4(C3);
	if(C4.R != 8 || C4.G != 8 || C4.B != 8) return -1;

	cout << "	::CColor - Constructeurs : OK" << endl;
	return 0;
}

int CColor_TestPublicMethods()
{
	cout << "	::CColor - Test des méthodes publiques..." << endl;

	CColor C1(7, -1, 0.4);
	C1.Saturate();

	if(C1.R != 1 || C1.G != 0 || C1.B != 0.4) return -1;

	cout << "	::CColor - Méthodes publiques : OK" << endl;

	return 0;
}

int CColor_TestStaticMethods()
{
	return 0;
}
